<template>
  <div class="login_content">
   <van-cell-group>
       <van-field
    v-model="password"
    type="password"
    label="密码"
    placeholder="请输入密码"
    required
  
  />  
  <van-field
    v-model="username"
    required
    clearable
    label="用户名"
    right-icon="question-o"
    placeholder="请输入用户名"
    @click-right-icon="$toast('question')"
  />


  <van-field
    v-model="password"
    type="password"
    label="密码"
    placeholder="请输入密码"
    required
  />
</van-cell-group>
    <van-button
      @click="submitLogin"
      type="primary"
    >登录</van-button>
    <a style="float:right;font-size:12px;color:blue;">免费注册</a>
  </div>
</template>

<script>
import qs from 'qs'
import { mobile } from '@/api'
export default {
  data () {
    return {
      username: '',
      password: ''
    }
  },
  methods: {
    submitLogin () {
      mobile.login({
        username: this.username,
        password: this.password
      }).then(res => {
        console.log(res)
        if (res.data.success) {
          this.$toast.success('登录成功')
          location.href = qs.parse(location.href.split('?')[location.href.split('?').length - 1]).repath
        } else {
          this.$toast.fail(res.data.message)
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.login_content {
  padding: 0 20px;
  .van-button {
    margin: 30px 0;
    width: 100%;
    background-color: #1989fa;
  }
}
// .asdfsd{
//     margin-top: 50;
// }
</style>
